export default {
	namespaced: true,
	state: () => ({
		address: JSON.parse(uni.getStorageSync('address') || '{}'),
		//用户信息
		userInfo: JSON.parse(uni.getStorageSync('userInfo') || '{}'),
		//token: uni.getStorageSync('token')
		token: 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1aWQiOjQ5LCJpYXQiOjE2NTY4MzM3MzUsImV4cCI6MTAwMTY1NjgzMzczNH0.0rYXe_WJxpr5NIadbHObwEOrEFsb2zibDcV7vmZvv78',
		redirectInfo: {
			//跳转回页面的路径
			//页面的类型
		}
	}),
	mutations: {
		//设置重定向参数
		updateRedirectInfo(state, obj) {
			state.redirectInfo = obj
			console.log(state.redirectInfo)
		},
		//保存token
		updateToken(state, token) {
			state.token = token
			uni.setStorageSync('token', token)
		},
		//保存用户信息
		updateUserInfo(state, userInfo) {
			state.userInfo = userInfo
			uni.setStorageSync('userInfo', JSON.stringify(userInfo))
		},
		//保存收货地址
		updateAddress(state, address) {
			state.address = address
			uni.setStorageSync('address', JSON.stringify(address))
		}
	},
	getters: {
		addstr(state) {
			return `${state.address.provinceName}${state.address.cityName}${state.address.countyName}${state.address.detailInfo}`
		}
	}
}
